const { ccclass, property } = cc._decorator;

@ccclass
export default class RankItemCtrl extends cc.Component {
    @property(cc.Label)
    rankLabel = null;

    @property(cc.Label)
    placeLabel = null;

    @property(cc.Label)
    experienceLabel = null;

    @property([cc.SpriteFrame])
    rankSpArr = [];

    initData(index) {
        if (index) {
            const data = [
                {
                    rank: "Top1",
                    place: "西双版纳",
                    experience: "亲近大象/丛林飞跃/探访傣村/打卡夜市"
                },
                {
                    rank: "Top2",
                    place: "万宁",
                    experience: "选个酒店躺平度假"
                },
                {
                    rank: "Top3",
                    place: "涠洲岛",
                    experience: "一定不能错过的海边日落！"
                },
                {
                    rank: "Top4",
                    place: "成都",
                    experience: "看大熊猫！美食大盘点！"
                },
                {
                    rank: "Top5",
                    place: "重庆",
                    experience: "巴适的山城魅力"
                },
                {
                    rank: "Top6",
                    place: "三亚",
                    experience: "购物天堂，buybuybuy"
                },
                {
                    rank: "Top7",
                    place: "长沙",
                    experience: "嗦一碗当地人每天必不可少的米粉"
                },
                {
                    rank: "Top8",
                    place: "青岛",
                    experience: "红瓦绿树，碧海蓝天"
                },
                {
                    rank: "Top9",
                    place: "南澳岛",
                    experience: "不一样的岛上风情"
                },
                {
                    rank: "Top10",
                    place: "西安",
                    experience: "十三朝之都，历史的文化宝藏"
                }
            ];

            const { rank, place, experience } = data[index];
            this.rankLabel.string = rank;
            this.placeLabel.string = place;
            this.experienceLabel.string = experience;
            this.node.getComponent(cc.Sprite).spriteFrame = this.rankSpArr[index];
        }
    }
}